<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
$this->title = '默认图片设置';
?>
<?= Html::cssFile('./assets/css/uploadsoft.css')?>
<?= Html::jsFile('./assets/uploadsoft/jquery.min.js')?>
<?= Html::jsFile('./assets/uploadsoft/jquery.form.js')?>
<?= Html::jsFile('./assets/js/systemupload.js')?>
<div class="container">
	<div class="row">

		<?php echo $this->render('_leftnav') ?>

		<div class="col-md-10">
			<div class="page-header clearfix">
				<h1 class="pull-left">默认图片</h1>
				<div class="pull-right">


				</div>
			</div>

			<?php echo $this->render('_usersetting') ?>


			<fieldset>
				<div class="form-group">
					<div class="col-md-3 control-label"></div>
					<div class="controls col-md-8 radios" id="default-avatar">
						<div class="form-group" id="avatar-class" style="display:block;">
							<div class="col-md-8 control-label">
								<b>系统默认图片</b>
								<br>
								<span>网校内未上传头像的用户，都会显示该默认图片。推荐尺寸（128*128）</span>
							</div>


							<?php
							$form = ActiveForm::begin([
								'options' => ['id'=>'site-form','enctype' => 'multipart/form-data'],
								'action'=>Url::to(['system/defaultsave']),
								'method'=>'post',
								'fieldConfig' => [
									'template' => '{input}{error}'
								],
							]);
							?>

							<!--			  <form id="avatar-form" method="post">-->
							<div class="controls col-md-8 controls choose" id="old">
								<img src="http://files.bwphp.com/file/image/show/128/128?path=<?php echo $model->course_photo;?>" width="128px" height="128px">
							</div>
							<div class="form-group">
								<div class="col-md-2 control-label"></div>
								<div class="controls col-md-8 controls">
									<p class="help-block">你可以上传JPG、GIF或PNG格式的文件。</p>
									<div class="form-group" style="margin-left:0px" >
										<input type="hidden" id="system_thumb" name="DefaultForm[course_photo]">
										<div class="btn" style="">
											<span>添加图片</span>
											<?= Html::fileInput('filedata','', ['id'=>'fileupload']) ?>
										</div>
										<div class="progress" style='margin-left:100px'>
											<span class="bar"></span><span class="percent">0%</span >
										</div>
										<div class="files" style='margin-left:0px'></div>
										<div id="showimg"></div>
									</div>
								</div>
							</div>

							<div class="form-group">
								<div class="col-md-2 control-label"></div>
								<div class="controls col-md-8 controls">

								</div>
							</div>

						</div>

					</div>
				</div>
			</fieldset>
			<div class="form-group mll">
				<div class="col-md-3 control-label"></div>
				<div class="controls col-md-8">
					<?= Html::submitButton('提交', ['class'=>'btn btn-primary mtl']) ?>
				</div>
				<input name="defaultAvatar" value="0" type="hidden">
			</div>
			<?php ActiveForm::end();?>
		</div>
	</div>
</div>
<script>
	$("#change_img").change(function() {
		var file = document.getElementById("change_img").files[0];
		var tmpimg=document.createElement('img');
		tmpimg.src=window.URL.createObjectURL(file);
		tmpimg.style.width = '128px';
		tmpimg.style.hight = '128px';
		$('.choose').replaceWith('<div class="controls col-md-8 controls choose new" id="old"></div>');
		$(".new").html(tmpimg);
	});
</script>